/**
 * 
 */
package com.aat.dxfy.thread.safe1;

/**
 * @date 2016年6月23日 下午12:59:42
 * @author 新歌<xingeking@163.com>
 * @email xingeking@163.com
 * @version v1.0
 * @function 功能是：
 * @info java spring
 * @update none
 */
public class Test01 {

	public static void main(String[] args) {
		String s1 = "adaesfdwqacafewrvwaddrsdrvcaaaasadasedaadaesdfavsdfvsdf";
		String s2 = "adaesfdwaaqacsdrvcasadasedaadaesdfavsdfvsdf";
		String s3 = "ahhhhedwqeweaadaesfdwqcsdrvcsadasedaadaesdfavsdfvsdf";
		A a1 = new A(s1);
		A a2 = new A(s2);
		A a3 = new A(s3);
		a1.start();
		a2.start();
		a3.start();
		
		int res = a1.getCount() + a2.getCount() + a3.getCount();
		System.out.println("Res " + res);
		
	}

}

class A extends Thread {
	private int count = 0;
	private String s;

	A(String s) {
		this.s = s;
	}

	public int getCount() {
		return count;
	}

	public void run() {
		char[] cs = s.toCharArray();
		for (int i = 0; i < cs.length; i++) {
			if (cs[i] == 'a') {
				count++;
			}
		}
		try {
			Thread.sleep(1000);
			System.out.println(count);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

}